﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="WebHoiChoMuaBan.Models" %>
<%@ Import Namespace="WebHoiChoMuaBan.Controllers.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    CreateCategory
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadHolder" runat="server">
    <style type="text/css" media="screen">
        .error
        {
            font-weight: Bold;
            color: Red;
        }
        .text
        {
            width: 210px;
            float: left;
        }
        .baroption
        {
            background-color: #DBDBDB;
        }
        .ddownlist
        {
            width: 230px;
        }
        .description
        {
            width: 200px;
        }
        .link
        {
            margin-left: 10px;
        }
    </style>
    <script type="text/javascript" src="/../Scripts/Category.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //Hàm khởi tạo để disable các combobox
            init();
            //Bật tắt dropdownlist 1
            $("#ckb_dm1").click(function () {
                switchstate_dm1();
            });
            //Bật tắt dropdownlist 2
            $("#ckb_dm2").click(function () {
                switchstate_dm2();
            });

            $("#ckb_modal_dm1").click(function () {
                switchstate_modal_dm1();
            });
            //Bật tắt dropdownlist 2
            $("#ckb_modal_dm2").click(function () {
                switchstate_modal_dm2();
            });


            //Bật tắt link
            $("#ckbLink").click(function () {
                switchstate_link();
            });

            //Hàm set giá trị "" cho textbox "Tên danh mục"
            $("input").click(function () {
                $(this).val("");
            });
            //Hàm gán lại giá trị cho textbox khi sự kiện blur xảy ra
            $("#txtCateName").blur(function () {
                if ($(this).val() == "")
                    $(this).val("Tạo danh mục...");
            });
            //Hàm gán lại giá trị cho textbox khi sự kiện blur xảy ra
            $("#txtLinkInput").blur(function () {
                if ($(this).val() == "")
                    $(this).val("Nhập link...");
            });

            $("#ddlCateLevel1").change(function () {
                $.ajax({
                    type: "POST",
                    url: "/Utility/SelectChildCategory",
                    data: "parentID=" + $(this).val(),
                    success: function (result) {
                        if (result.success) {
                            $("#ddlCateLevel2").empty();
                            $.each(result.data, function (index, optionData) {
                                $("#ddlCateLevel2").append("<option value='" + optionData.Value + "'>" + optionData.Text + "</option>");
                            });
                        }
                        test();
                    },
                    error: function (req, status, error) {
                        alert("Sorry! We could not receive your feedback at this time.");
                    }
                });
            });


            $("#ddlModalCateLevel1").change(function () {
                $.ajax({
                    type: "POST",
                    url: "/Utility/SelectChildCategory",
                    data: "parentID=" + $(this).val(),
                    success: function (result) {
                        if (result.success) {
                            $("#ddlModalCateLevel2").empty();
                            $.each(result.data, function (index, optionData) {
                                $("#ddlModalCateLevel2").append("<option value='" + optionData.Value + "'>" + optionData.Text + "</option>");
                            });
                        }
                    },
                    error: function (req, status, error) {
                        alert("Sorry! We could not receive your feedback at this time.");
                    }
                });
            });

            $("#ddlSearchCateLevel1").change(function () {
                $.ajax({
                    type: "POST",
                    url: "/Utility/SelectChildCategory",
                    data: "parentID=" + $(this).val(),
                    success: function (result) {
                        if (result.success) {
                            $("#ddlSearchCateLevel2").empty();
                            var resultString = "";
                            resultString += "<tr>";
                            resultString += "<td width='3%'>";
                            resultString += "<input id='checkbox' class='input_checkbox' type='checkbox' name='checkbox'>";
                            resultString += "</td>";
                            resultString += "<td width='25%'>";
                            resultString += "<p class='font_bold'>";
                            resultString += "Danh mục</p>";
                            resultString += "</td>";
                            resultString += "<td width='10%' align='center'>";
                            resultString += "<p class='font_bold'>";
                            resultString += "Trạng thái</p>";
                            resultString += "</td>";
                            resultString += "<td width='17%'>";
                            resultString += "</td>";
                            resultString += "</tr>";
                            $.each(result.data, function (index, optionData) {
                                $("#ddlSearchCateLevel2").append("<option value='" + optionData.Value + "'>" + optionData.Text + "</option>");
                                resultString += "<tr>";
                                resultString += "<td>";
                                resultString += "<input id='catLevel1" + optionData.Value + "' class='input_checkbox' type='checkbox' name='catLevel1" + optionData.Value + "' />";
                                resultString += "</td>";
                                resultString += "<td>";
                                resultString += "<p class='font_bold'>" + optionData.Text + "</p>";
                                resultString += "</td>";
                                resultString += "<td>";
                                resultString += " <a href='#'>Xuất bản</a>";
                                resultString += "</td>";
                                resultString += "<td align='right'>";
                                resultString += "<div class='private_button_upload col_right'>";
                                resultString += "<a href='#' onclick='deleteCategory(" + optionData.Value + ")'>";
                                resultString += "<img src='../../Content/Images/icon_plus_up.gif'>";
                                resultString += "Xóa</a></div>";
                                resultString += "<div class='private_button_upload col_right hoicho_margin_leftright'>";
                                resultString += "<a href='#' class='modalInput' rel='.prompt' onclick='editCategory(" + optionData.Value + ")'>";
                                resultString += "<img src='../../Content/Images/icon_plus_up.gif'>";
                                resultString += "Sửa</a></div></td>";
                                resultString += "</tr>";
                                var ff = document.getElementById("TableSearchCategory");
                                ff.innerHTML = resultString;
                                modalInit();
                            });
                        }
                    },
                    error: function (req, status, error) {
                        alert("Sorry! We could not receive your feedback at this time.");
                    }
                });

            });


            $("#ddlSearchCateLevel2").change(function () {
                $.ajax({
                    type: "POST",
                    url: "/Utility/mySelectChildLevel2Category",
                    data: "cateID=" + $(this).val(),
                    success: function (result) {
                        if (result.success) {
                            //$("#ddlCateLevel2").empty();
                            var resultString = "";
                            resultString += "<tr>";
                            resultString += "<td width='3%'>";
                            resultString += "<input id='checkbox' class='input_checkbox' type='checkbox' name='checkbox'>";
                            resultString += "</td>";
                            resultString += "<td width='25%'>";
                            resultString += "<p class='font_bold'>";
                            resultString += "Danh mục</p>";
                            resultString += "</td>";
                            resultString += "<td width='10%' align='center'>";
                            resultString += "<p class='font_bold'>";
                            resultString += "Trạng thái</p>";
                            resultString += "</td>";
                            resultString += "<td width='17%'>";
                            resultString += "</td>";
                            resultString += "</tr>";
                            $.each(result.data, function (index, optionData) {
                                resultString += "<tr>";
                                resultString += "<td>";
                                resultString += "<input id='catLevel1" + optionData.Value + "' class='input_checkbox' type='checkbox' name='catLevel1" + optionData.Value + "' />";
                                resultString += "</td>";
                                resultString += "<td>";
                                resultString += "<p class='font_bold'>" + optionData.Text + "</p>";
                                resultString += "</td>";
                                resultString += "<td>";
                                resultString += " <a href='#'>Xuất bản</a>";
                                resultString += "</td>";
                                resultString += "<td align='right'>";
                                resultString += "<div class='private_button_upload col_right'>";
                                resultString += "<a href='#' onclick='deleteCategory(" + optionData.Value + ")'>";
                                resultString += "<img src='../../Content/Images/icon_plus_up.gif'>";
                                resultString += "Xóa</a></div>";
                                resultString += "<div class='private_button_upload col_right hoicho_margin_leftright'>";
                                resultString += "<a href='#' class='modalInput' rel='.prompt' onclick='editCategory(" + optionData.Value + ")'>";
                                resultString += "<img src='../../Content/Images/icon_plus_up.gif'>";
                                resultString += "Sửa</a></div></td>";
                                resultString += "</tr>";
                                var ff = document.getElementById("TableSearchCategory");
                                ff.innerHTML = resultString;
                                modalInit();
                            });
                        }
                        else {
                            alert("Không tồn tại dữ liệu");
                        }
                    },
                    error: function (req, status, error) {
                        alert("Sorry! We could not receive your feedback at this time.");
                    }
                });
            });

        });
    </script>
    <script type="text/javascript">
        function deleteCategory(cateId) {
            var loader = document.getElementById("SearchLoader");
            $.ajax({
                type: "POST",
                url: "/CreateCategory/deleteCategory",
                data: "cateId=" + cateId,
                beforeSend: function (result) {
                    loader.innerHTML = "<img src='../../Content/Images/fb_loader.gif' />";
                },
                success: function (result) {
                    if (result.indexOf("done") != -1) {
                        alert("Xóa thư mục thành công");
                        loader.innerHTML = "";
                        $.ajax({
                            type: "POST",
                            url: "/Utility/mySelectChildLevel2Category",
                            data: "cateID=" + result.split("@")[1],
                            success: function (result) {
                                if (result.success) {
                                    $("#ddlCateLevel2").empty();
                                    var resultString = "";
                                    resultString += "<tr>";
                                    resultString += "<td width='3%'>";
                                    resultString += "<input id='checkbox' class='input_checkbox' type='checkbox' name='checkbox'>";
                                    resultString += "</td>";
                                    resultString += "<td width='25%'>";
                                    resultString += "<p class='font_bold'>";
                                    resultString += "Danh mục</p>";
                                    resultString += "</td>";
                                    resultString += "<td width='10%' align='center'>";
                                    resultString += "<p class='font_bold'>";
                                    resultString += "Trạng thái</p>";
                                    resultString += "</td>";
                                    resultString += "<td width='17%'>";
                                    resultString += "</td>";
                                    resultString += "</tr>";
                                    $.each(result.data, function (index, optionData) {
                                        resultString += "<tr>";
                                        resultString += "<td>";
                                        resultString += "<input id='catLevel1" + optionData.Value + "' class='input_checkbox' type='checkbox' name='catLevel1" + optionData.Value + "' />";
                                        resultString += "</td>";
                                        resultString += "<td>";
                                        resultString += "<p class='font_bold'>" + optionData.Text + "</p>";
                                        resultString += "</td>";
                                        resultString += "<td>";
                                        resultString += " <a href='#'>Xuất bản</a>";
                                        resultString += "</td>";
                                        resultString += "<td align='right'>";
                                        resultString += "<div class='private_button_upload col_right'>";
                                        resultString += "<a href='#' onclick='deleteCategory(" + optionData.Value + ")'>";
                                        resultString += "<img src='../../Content/Images/icon_plus_up.gif'>";
                                        resultString += "Xóa</a></div>";
                                        resultString += "<div class='private_button_upload col_right hoicho_margin_leftright'>";
                                        resultString += "<a href='#' class='modalInput' rel='.prompt' onclick='editCategory(" + optionData.Value + ")'>";
                                        resultString += "<img src='../../Content/Images/icon_plus_up.gif'>";
                                        resultString += "Sửa</a></div></td>";
                                        resultString += "</tr>";
                                        var ff = document.getElementById("TableSearchCategory");
                                        ff.innerHTML = resultString;
                                        modalInit();
                                    });
                                }
                                else {
                                    alert("Không tồn tại dữ liệu");
                                }
                            },
                            error: function (req, status, error) {
                                alert("Sorry! We could not receive your feedback at this time.");
                            }
                        });
                    }
                    else {
                        if (result == "product") {
                            alert("Không thể xóa thư mục có chứa sản phẩm");
                        }
                        else alert("Không thể xóa thư mục có chứa thư mục con");
                    }
                },
                error: function (req, status, error) {
                    alert("Sorry! We could not receive your feedback at this time.");
                }
            });
        }
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".modalInput").click(function () {
                $('#ddlModalCateLevel2').show();
                $('#ckb_modal_dm2').show();
            });
        });
    </script>
    <script type="text/javascript">
        function modalInit() {
            $(document).ready(function () {

                var triggers = $(".modalInput").overlay({

                    // some mask tweaks suitable for modal dialogs
                    mask: {
                        color: '#ebecff',
                        loadSpeed: 200,
                        opacity: 0.9
                    },

                    closeOnClick: false
                });

                var buttons = $("#yesno button").click(function (e) {

                    // get user input
                    var yes = buttons.index(this) === 0;

                    // do something with the answer
                    triggers.eq(0).html("You clicked " + (yes ? "yes" : "no"));
                });

                $(".prompt form").submit(function (e) {

                    // close the overlay
                    triggers.eq(1).overlay().close();
                    // get user input
                    var input = $("input", this).val();

                    // do something with the answer
                    triggers.eq(1).html(input);

                    // do not submit the form
                    //  return e.preventDefault();
                });
            });
        }
        modalInit();
    </script>
    <script type="text/javascript">

        function editCategory(cateId) {
            var ff = document.getElementById("ModalID");
            var gg = document.getElementById("ModalTenDanhMuc");
            ff.value = "";
            gg.value = "";
            //thiết lập infor for modal pop up
            $.ajax({
                type: "POST",
                url: "/CreateCategory/getCategoryInfo",
                data: "cateId=" + cateId,
                success: function (result) {
                    var object = jQuery.parseJSON(result);
                    var resultString;
                    ff.value = object[0]["CateId"];
                    gg.value = object[0]["CateName"] + "";
                    //nếu là danh mục cấp 2
                    if (object[0]["ParrentCateId"] != null) {
                        $('#ddlModalCateLevel2').hide();
                        $('#ckb_modal_dm2').hide();
                    }
                    else {
                        if (parseInt(object[0]["CateCount"]) == 0) {
                        }
                        else {
                            $('#ddlModalCateLevel2').hide();
                            $('#ckb_modal_dm2').hide();
                        }
                    }
                },
                error: function (req, status, error) {
                    alert("Sorry! We could not receive your feedback at this time.");
                }
            });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="hoicho_content_maingroup">
        <div class="col_left hoicho_marin_leftright content_right">
            <!-- Tìm kiếm danh mục -->
            <div class="private_count_news hoicho_margin_topbottom">
                <%=Html.ValidationSummary("Vui lòng nhập đầy đủ thông tin.", new { @class= "error"})%>
                <form action="<%= Url.Action("addCategory","CreateCategory") %>" method="post" enctype="multipart/form-data">
                <table width="100%" border="0">
                    <tr>
                        <td>
                            <%--<input type="text" id="" value="Tạo danh mục" style="width:245px;"/>--%>
                            <div class="description">
                                Tên danh mục</div>
                            <%= Html.TextBox("txtCateName", (ViewData["CateName"] == null ? "Tạo danh mục..." : ViewData["CateName"].ToString()), new { @class = "text" })%>
                            <input type="checkbox" id="ckb_dm1" class="input_checkbox" name="ckb_dm1" />
                            <%--<select style="width:245px" id="select2" name="select2"><option>Danh mục con 1</option></select>--%>
                            <% 
                                List<PageType> lstPages = (List<PageType>)ViewData["Pages"];
                                if (lstPages == null)
                                {
                                    Response.Write("<select id='ddlCateLevel1' name='ddlCateLevel1' class='ddownlist' >");
                                    Response.Write("<option value='-1'>Tạo danh mục cấp 1...</option>");
                                    Response.Write("</select>");
                                }
                                else
                                {
                                    Response.Write("<select id='ddlCateLevel1' name='ddlCateLevel1' class='ddownlist' >");
                                    Response.Write("<option value='-1'>Tạo danh mục cấp 1...</option>");
                                    foreach (var item in lstPages)
                                    {
                                        if (Session["SelectedPage"] != null)
                                        {
                                            if (((int)Session["SelectedPage"]) == item.PageId)
                                                Response.Write("<option value='" + item.PageId + "' selected='selected'>" + item.PageName + "</option>");
                                            else
                                                Response.Write("<option value='" + item.PageId + "'>" + item.PageName + "</option>");
                                        }
                                        else
                                            Response.Write("<option value='" + item.PageId + "'>" + item.PageName + "</option>");
                                    }
                                    Response.Write("</select>");
                                }
                            %>
                            <input type="checkbox" id="ckb_dm2" class="input_checkbox" name="ckb_dm2" />
                            <%--<select style="width:245px" id="select2" name="select2"><option>Danh mục con 2</option></select>--%>
                            <% 
                                List<Category> cateLevel1 = (List<Category>)ViewData["CateLevel1"];
                                if (cateLevel1 == null)
                                {
                                    Response.Write("<select id='ddlCateLevel2' name='ddlCateLevel2' class='ddownlist'>");
                                    Response.Write("<option value='-1'>Tạo danh mục cấp 2...</option>");
                                    Response.Write("</select>");
                                }
                                else
                                {
                                    Response.Write("<select id='ddlCateLevel2' name='ddlCateLevel2' class='ddownlist' >");
                                    Response.Write("<option value='-1'>Tạo danh mục cấp 2...</option>");
                                    foreach (var item in cateLevel1)
                                    {
                                        Response.Write("<option value='" + item.CateId + "'>" + item.CateName + "</option>");
                                    }
                                    Response.Write("</select>");
                                }
                            %>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div style="width: 250px; float: left">
                                <div class="description">
                                    Icon menu chinh</div>
                                <input type="file" id="pageIcon" name="pageIcon" />
                            </div>
                            <%--   <div style="width: 230px; float: left">
                                <div class="description">
                                    Hình danh mục cấp 1</div>
                                <input type="file" id="cateImg" name="cateImg" />
                            </div>--%>
                            <div style="width: 310px; float: right; padding-top: 16px">
                                <%--  <input type="checkbox" id="ckbLink" class="input_checkbox" name="ckbLink" />--%>
                                <%--<input type="text" id="" value="Nhập link" style="width:220px;"/>--%>
                                <%--           <%= Html.TextBox("txtLinkInput", (ViewData["PageType"] == null ? "Nhập link..." : ((PageType)ViewData["PageType"]).PageUrl), new { @class = "text link" })%>--%>
                            </div>
                            <div style="clear: both;">
                            </div>
                            <div>
                                <center>
                                    <input type="submit" value="Save" class="hoicho_bt_submit_reg" style="width: 60px" />
                                </center>
                            </div>
                        </td>
                    </tr>
                </table>
                </form>
            </div>
            <!-- End Tìm kiếm danh mục -->
            <div class="content_group hoicho_margin_topbottom">
                <span class="hoicho_margin_right font_bold">Danh mục đã tạo:</span>
                <% 
                    if (lstPages == null)
                    {
                        Response.Write("<select id='ddlSearchCateLevel1' name='ddlSearchCateLevel1' class='ddownlist' >");
                        Response.Write("<option value='-1'>Tạo danh mục cấp 1...</option>");
                        Response.Write("</select>");
                    }
                    else
                    {
                        Response.Write("<select id='ddlSearchCateLevel1' name='ddlSearchCateLevel1' class='ddownlist' >");
                        Response.Write("<option value='-1'>Tạo danh mục cấp 1...</option>");
                        foreach (var item in lstPages)
                        {
                            if (Session["SelectedPage"] != null)
                            {
                                if (((int)Session["SelectedPage"]) == item.PageId)
                                    Response.Write("<option value='" + item.PageId + "' selected='selected'>" + item.PageName + "</option>");
                                else
                                    Response.Write("<option value='" + item.PageId + "'>" + item.PageName + "</option>");
                            }
                            else
                                Response.Write("<option value='" + item.PageId + "'>" + item.PageName + "</option>");
                        }
                        Response.Write("</select>");
                    }
                %>
                <% 
                              
                    if (cateLevel1 == null)
                    {
                        Response.Write("<select id='ddlSearchCateLevel2' name='ddlSearchCateLevel2' class='ddownlist'>");
                        Response.Write("<option value='-1'>Tạo danh mục cấp 2...</option>");
                        Response.Write("</select>");
                    }
                    else
                    {
                        Response.Write("<select id='ddlSearchCateLevel2' name='ddlSearchCateLevel2' class='ddownlist' >");
                        Response.Write("<option value='-1'>Tạo danh mục cấp 2...</option>");
                        foreach (var item in cateLevel1)
                        {
                            Response.Write("<option value='" + item.CateId + "'>" + item.CateName + "</option>");
                        }
                        Response.Write("</select>");
                    }
                %>
            </div>
            <div class="content_group">
                <div class="col_left content_group hoicho_margin_topbottom">
                   <%-- <div class="private_button_upload col_left">
                        <a href="photo_dangtai_private.html">
                            <img src="../../Content/Images/icon_plus_up.gif">
                            Sửa</a>
                    </div>
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="photo_dangtai_private.html">
                            <img src="../../Content/Images/icon_plus_up.gif">
                            Xóa</a>
                    </div>
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="photo_dangtai_private.html">
                            <img src="../../Content/Images/icon_plus_up.gif">
                            Cắt</a>
                    </div>
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="photo_dangtai_private.html">
                            <img src="../../Content/Images/icon_plus_up.gif">
                            Dán</a>
                    </div>--%>
              <%--      <div class="private_button_upload col_left">
                        <a href="photo_dangtai_private.html">
                            <img src="../../Content/Images/icon_plus_up.gif">
                            Chuyển trạng thái</a>
                    </div>--%>
                    <% int page;
                       if (Request.QueryString.Get("Page") != null)
                           page = int.Parse(Request.QueryString.Get("Page"));
                       else
                           page = 1;

                       List<Category> parrCate = new CategoryHelper().GetListParentCategoryPagging(page);
                       int totalPages = (int)Math.Ceiling((double)new CategoryHelper().GetListParentCategory().Count() / 9);
                    %>
                    <div class="private_breakpage col_left hoicho_margin_leftright font_bold" style="text-align: right">
                        <%
                            int i;
                            int p = page;
                            string orginalUrl = HttpContext.Current.Request.Url.AbsoluteUri;
                            if (HttpContext.Current.Request.Url.Query.Length > 0)
                                orginalUrl = orginalUrl.Replace(HttpContext.Current.Request.Url.Query, string.Empty);
                            //if (Request.QueryString["Page"] != null && int.TryParse(Request.QueryString["Page"], out p))
                            //{
                        %>
                        <% if (p > 1)
                           { %><a href='<%=string.Format("{0}?Page={1}",
                                                    orginalUrl,
                                                    p-1) %>'><img src="/../Content/Images/arrow_breakpage_left.gif" alt="">&nbsp;Trang
                               trước</a>
                        <% } %>
                        <%
                            if (p > 3)
                                Response.Write(string.Format("<a href='{0}?Page={1}'>{2}</a> ",
                                                               orginalUrl,
                                                                1,
                                                                 1));
                            if (p > 4)
                                Response.Write("...");
                            int total = totalPages;
                            int from = (p - 2 < 1 ? 1 : p - 2);
                            int to = (p + 2 >= total ? total : p + 2);
                            for (i = from; i <= to; i++)
                                Response.Write(string.Format("<a href='{0}?Page={1}' {2}>{3}</a> ",
                                      orginalUrl,
                                                                i,
                                                                (i == p ? "class='menu_select'" : string.Empty),
                                                                 i));
                            if (p <= total - 4)
                                Response.Write("...");
                            if (p <= total - 3)
                                Response.Write(string.Format("<a href='{0}?Page={1}' {2}>{3}</a> ",
                                                               orginalUrl,
                                                                total,
                                                                string.Empty,
                                                                total));
                        %>
                        <% if (p < totalPages)
                           { %><a href='<%=string.Format("{0}?Page{1}'",
                                                    orginalUrl,
                                                    p+1) %>'>Trang sau&nbsp;<img src="/../Content/Images/arrow_breakpage_right.gif" alt=""></a>
                        <% } %>
                        <%-- <% }  %>--%>
                    </div>
                </div>
            </div>
            <div class="private_group_friend">
                <div id="SearchLoader">
                </div>
                <table width="100%" border="0" id="TableSearchCategory">
                    <tr bgcolor="#f5f7fb" class="border_bottom">
                        <td width="3%">
                            <input id="checkbox" class="input_checkbox" type="checkbox" name="checkbox">
                        </td>
                        <td width="25%">
                            <p class="font_bold">
                                Danh mục</p>
                        </td>
                        <%--      <td width="45%">
                            <p class="font_bold">
                                Add temp</p>
                        </td>--%>
                        <td width="10%" align="center">
                            <p class="font_bold">
                                Trạng thái</p>
                        </td>
                        <td width="17%">
                            &nbsp;
                        </td>
                    </tr>
                    <%
                      
                        foreach (Category item in parrCate)
                        {
                            Response.Write("<tr>");
                    %>
                    <td>
                        <input id="catLevel1<%=item.CateId %>" class="input_checkbox" type="checkbox" name="catLevel1<%=item.CateId %>" />
                    </td>
                    <td>
                        <p class="font_bold">
                            <%=item.CateName %></p>
                    </td>
                    <td align="center">
                        <a href="#">Xuất bản</a>
                    </td>
                    <%--              <center>
                    <%
                        string icon, msg, actionUrl;
                        if (mem.MemStatus == (char?)WebHoiChoMuaBan.Models.Member.Status.Active)
                        {
                            icon = "ui-icon-check";
                            msg = "Đang kích hoạt. Hãy nhấn nút để Khóa";
                            actionUrl = "LockMember";
                        }
                        else
                        {
                            icon = "ui-icon-locked";
                            msg = "Đang bị khóa. Hãy nhấn nút để Kích hoạt";
                            actionUrl = "ActivateMember";
                        }
                    %>
                    <a href="/Admin/Member/<%=actionUrl %>?id=<%=mem.MemId %>" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only"
                        title="<%=msg %>"><span class="ui-button-icon-primary ui-icon <%=icon %> "></span>
                        <span class="ui-button-text">Button with icon only</span> </a>
          
            </center>--%>
                    <td align="right">
                        <div class="private_button_upload col_right">
                            <a href="#" onclick="deleteCategory(<%=item.CateId %>)">
                                <img src="../../Content/Images/icon_plus_up.gif">
                                Xóa</a>
                        </div>
                        <div class="private_button_upload col_right hoicho_margin_leftright">
                            <a href="#" class="modalInput" rel=".prompt" onclick="editCategory(<%=item.CateId %>)">
                                <img src="../../Content/Images/icon_plus_up.gif">
                                Sửa</a>
                        </div>
                    </td>
                    <%
                        Response.Write("</tr>");
                        }
                    %>
                </table>
                <div class="modal prompt">
                    <h2>
                        Thay đổi thông tin danh mục</h2>
                    <!-- input form. you can press enter too -->
                    <form action="<%= Url.Action("editCategory","CreateCategory") %>" method="post" enctype="multipart/form-data">
                    <div id="ModalCategory" style="margin: 5px;">
                        <input type="text" id="ModalID" name="ModalID" class="ModalID hidden" />
                        Tên danh mục:
                        <input type="text" style="width: 200px;" id="ModalTenDanhMuc" name="ModalTenDanhMuc"
                            class="ModalTenDanhMuc" />
                    </div>
                    <center>
                        <input type="checkbox" id="ckb_modal_dm1" class="input_checkbox" name="ckb_modal_dm1" />
                        <% 
                            if (lstPages == null)
                            {
                                Response.Write("<select id='ddlModalCateLevel1' name='ddlModalCateLevel1' class='ddownlist' >");
                                Response.Write("<option value='-1'>Tạo danh mục cấp 1...</option>");
                                Response.Write("</select>");
                            }
                            else
                            {
                                Response.Write("<select id='ddlModalCateLevel1' name='ddlModalCateLevel1' class='ddownlist' >");
                                Response.Write("<option value='-1'>Tạo danh mục cấp 1...</option>");
                                foreach (var item in lstPages)
                                {
                                    if (Session["SelectedPage"] != null)
                                    {
                                        if (((int)Session["SelectedPage"]) == item.PageId)
                                            Response.Write("<option value='" + item.PageId + "' selected='selected'>" + item.PageName + "</option>");
                                        else
                                            Response.Write("<option value='" + item.PageId + "'>" + item.PageName + "</option>");
                                    }
                                    else
                                        Response.Write("<option value='" + item.PageId + "'>" + item.PageName + "</option>");
                                }
                                Response.Write("</select>");
                            }
                        %>
                        <br />
                        <input type="checkbox" id="ckb_modal_dm2" class="input_checkbox" name="ckb_modal_dm2" />
                        <% 
                              
                            if (cateLevel1 == null)
                            {
                                Response.Write("<select id='ddlModalCateLevel2' name='ddlModalCateLevel2' class='ddownlist'>");
                                Response.Write("<option value='-1'>Tạo danh mục cấp 2...</option>");
                                Response.Write("</select>");
                            }
                            else
                            {
                                Response.Write("<select id='ddlModalCateLevel2' name='ddlModalCateLevel2' class='ddownlist' >");
                                Response.Write("<option value='-1'>Tạo danh mục cấp 2...</option>");
                                foreach (var item in cateLevel1)
                                {
                                    Response.Write("<option value='" + item.CateId + "'>" + item.CateName + "</option>");
                                }
                                Response.Write("</select>");
                            }
                        %>
                        <br />
                        <button type="submit">
                            OK
                        </button>
                        <button type="button" class="close">
                            Cancel
                        </button>
                    </center>
                    </form>
                    <br />
                </div>
                <br />
            </div>
            <div class="content_group">
                <div class="col_left content_group hoicho_margin_topbottom">
                 <%--   <div class="private_button_upload col_left">
                        <a href="photo_dangtai_private.html">
                            <img src="../../Content/Images/icon_plus_up.gif">
                            Sửa</a>
                    </div>
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="photo_dangtai_private.html">
                            <img src="../../Content/Images/icon_plus_up.gif">
                            Xóa</a>
                    </div>
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="photo_dangtai_private.html">
                            <img src="../../Content/Images/icon_plus_up.gif">
                            Cắt</a>
                    </div>
                    <div class="private_button_upload col_left hoicho_margin_leftright">
                        <a href="photo_dangtai_private.html">
                            <img src="../../Content/Images/icon_plus_up.gif">
                            Dán</a>
                    </div>
                    <div class="private_button_upload col_left">
                        <a href="photo_dangtai_private.html">
                            <img src="../../Content/Images/icon_plus_up.gif">
                            Chuyển trạng thái</a>
                    </div>--%>
                    <div class="private_breakpage col_left hoicho_margin_leftright font_bold" style="text-align: right">
                        <%
                             
                            p = page;
                            orginalUrl = HttpContext.Current.Request.Url.AbsoluteUri;
                            if (HttpContext.Current.Request.Url.Query.Length > 0)
                                orginalUrl = orginalUrl.Replace(HttpContext.Current.Request.Url.Query, string.Empty);
                            //if (Request.QueryString["Page"] != null && int.TryParse(Request.QueryString["Page"], out p))
                            //{
                        %>
                        <% if (p > 1)
                           { %><a href='<%=string.Format("{0}?Page={1}",
                                                    orginalUrl,
                                                    p-1) %>'><img src="/../Content/Images/arrow_breakpage_left.gif" alt="">&nbsp;Trang
                               trước</a>
                        <% } %>
                        <%
                            if (p > 3)
                                Response.Write(string.Format("<a href='{0}?Page={1}'>{2}</a> ",
                                                               orginalUrl,
                                                                1,
                                                                 1));
                            if (p > 4)
                                Response.Write("...");
                            total = totalPages;
                            from = (p - 2 < 1 ? 1 : p - 2);
                            to = (p + 2 >= total ? total : p + 2);
                            for (i = from; i <= to; i++)
                                Response.Write(string.Format("<a href='{0}?Page={1}' {2}>{3}</a> ",
                                      orginalUrl,
                                                                i,
                                                                (i == p ? "class='menu_select'" : string.Empty),
                                                                 i));
                            if (p <= total - 4)
                                Response.Write("...");
                            if (p <= total - 3)
                                Response.Write(string.Format("<a href='{0}?Page={1}' {2}>{3}</a> ",
                                                               orginalUrl,
                                                                total,
                                                                string.Empty,
                                                                total));
                        %>
                        <% if (p < totalPages)
                           { %><a href='<%=string.Format("{0}?Page{1}'",
                                                    orginalUrl,
                                                    p+1) %>'>Trang sau&nbsp;<img src="/../Content/Images/arrow_breakpage_right.gif" alt=""></a>
                        <% } %>
                        <%-- <% }  %>--%>
                    </div>
                </div>
            </div>
        </div>
        <!-- End Content right -->
    </div>
</asp:Content>
